package com.gofaraway.common.enums;

/**
 * @author ChenPeng
 * @Date 2024/4/12 14:51
 */
public enum DisableEnum {

    /**
     * 有效
     */
    EFFECTIVE(0, "有效"),

    /**
     * 无效
     */
    DISABLE(1, "无效");


    private final String label;
    private final Integer value;

    DisableEnum(Integer value, String label) {
        this.label = label;
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public Integer getValue() {
        return value;
    }

    public static DisableEnum fromLabel(String label) {
        for (DisableEnum enumEntity : DisableEnum.values()) {
            if (enumEntity.getLabel().equals(label)) {
                return enumEntity;
            }
        }

        throw new RuntimeException();
    }

    public static DisableEnum fromValue(Integer value) {
        for (DisableEnum enumEntity : DisableEnum.values()) {
            if (enumEntity.getValue().equals(value)) {
                return enumEntity;
            }
        }

        throw new RuntimeException();
    }
}
